<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    request.setCharacterEncoding("UTF-8");
    String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=path%>/CSS/backLayout.css">
    <style type="text/css">
        .div_input {
            width: 500px;
            height: 40px;
        }
    </style>
</head>
<body style="background: #f5f5f5">
<div class="main">
    <div class="weizhi">
        基础资料>>财务基础资料>>收费项目>>新增
    </div>
    <%--提示的隐藏标识--%>
    <input type="hidden" id="alertType" value="${alertType}">
    <div class="div_body" style="box-shadow: 0 0 5px #cccccc;">
        <div class="div_form">
            <form action="<%=path%>/DrivingSys/add_pay_time" class="form" onsubmit="StopRepeat2()">
                <div class="fwrz">
                    <div class="div_input">
                        <span class="gn_name">财务组织&nbsp;:&nbsp;</span>
                        <input type="text" readonly="readonly" name="fcontrolunitid" value="${fnamel2}"
                               style="color: gray;">
                    </div>
                    <div class="div_input">
                        <span class="gn_name">编码&nbsp;:&nbsp;</span>
                        <input type="text" name="fnumber" readonly="readonly" value="${fnumber}" style="color: gray;">
                    </div>
                    <div class="div_input">
                        <span class="gn_name">名称&nbsp;:&nbsp;</span>
                        <input type="text" class="is_click" name="fnameL2" style="color: gray;">
                        <span class="required">必填</span>
                    </div>
                    <div class="div_input">
                        <span class="gn_name">简称&nbsp;:&nbsp;</span>
                        <input type="text" name="fsimplename">
                    </div>
                    <div class="div_input">
                        <span class="gn_name">金额&nbsp;:&nbsp;</span>
                        <input class="cfamount" type="text" name="cfamount">
                    </div>
                    <div class="div_input">
                        <span class="gn_name">描述&nbsp;:&nbsp;</span>
                        <input type="text" name="fdescriptionL2" id="gs">
                        <span style="font-size: 14px;color: red;display: none" class="haoyou">请输入数字</span>
                    </div>
                    <div class="div_tj" style="margin-left: 140px">
                        <div>
                            <input type="submit" class="input_submit bc" value="" style="margin-right: 30px;"/>
                        </div>
                        <div>
                            <input type="button" class="input_back fh" value="" onclick="back()"/>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<script !src="">
    //返回
    function back() {
        location = '<%=path%>/DrivingSys/select_pay_timet/look.action'
    }

    $(document).on('keyup', '.cfamount', function (event) {
        //最后一位是小数点的话，移除
        var $amountInput = $(this);
        //响应鼠标事件，允许左右方向键移动
        event = window.event || event;
        if (event.keyCode == 37 | event.keyCode == 39) {
            return;
        }
        var clazz = $(this).prop("class")
        //获取输入框的值
        var value = $(this).val();
        //判断负数是否在第一位
        if (value.substring(0, 1) == '-') {

        }
        if (value.length == 0) {
            $(this).val("0")
        }
        if (value.lastIndexOf('0') == 0) {
            $(this).val(value.substring(1, value.length))
            // $amountInput.val($amountInput.val().replace('-','')
        }
        //判断负数不是在第一位，替换
        if (value.lastIndexOf('-') >= 0) {
            $(this).val("0")
            // $amountInput.val($amountInput.val().replace('-','')
        }
        //先把非数字的都替换掉，除了数字和.
        $amountInput.val($amountInput.val().replace(/[^\-?\d]/g, ".").//只允许一个小数点
        replace(/^\./g, "").replace(/\.{2,}/g, ".").//只能输入小数点后两位
        replace(".", "$#$").replace(/\./g, "").replace("$#$", ".").replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'));
        if ($(this).val() == "") {
            $(this).val(0)
        }
    });
</script>
<%@ include file="/WEB-INF/JSP/ajax.jsp" %>
</html>